<%--
  Created by IntelliJ IDEA.
  Dept: admin
  Date: 2025/3/4
  Time: 11:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="/static/layui/css/layui.css">
    <style>
        #deptTable {
            width: 700px;
            margin: 0 auto;
        }

        p {
            text-align: center;
        }
    </style>
<%--
http://localhost:8080/demo0311_Web_exploded/dept
http://localhost:8080/static/layui/css/layui.css

在部署时需要删除/ 后面内容，以下是最新项目访问路径
http://localhost:8080/dept

--%>
</head>
<body>
<p>
    <a href="deptadd.jsp" class="layui-btn layui-bg-blue">新增部门</a>
    <%-- jstl标签以及el表达式  --%>
    部门表有${count}条记录
</p>
<hr>
<table id="deptTable" class="layui-table" lay-even>
    <tr>
        <td>编号</td>
        <td>部门名称</td>
        <td>负责人</td>
        <td>部门人数</td>
        <td>部门成立时间</td>
        <td>操作</td>
    </tr>
    <c:forEach items="${deptList}" var="dept">
        <tr>
            <td>${dept.id}</td>
            <td>${dept.dname}</td>
            <td>${dept.manager}</td>
            <td>${dept.num}</td>
            <td><fmt:formatDate value="${dept.createtime}"></fmt:formatDate></td>
            <td>
                <a class="layui-btn layui-btn-primary" href="toEditDept?id=${dept.id}">编辑</a>&nbsp;&nbsp;
                <a class="layui-btn layui-btn-danger" href="javascript:void(0)" onclick="deleteDept(${dept.id})">删除</a>
            </td>
        </tr>
    </c:forEach>
    <tr style="text-align: center">
        <td colspan="6">
            <a href="/dept?currentPage=1">首页</a>
            <c:if test="${page.currentPage != 1}">
                <a href="/dept?currentPage=${page.currentPage-1}">上一页</a>
            </c:if>
            第${page.currentPage}页/共${page.totalPage}页
            <c:if test="${page.currentPage != page.totalPage}">
                <a href="/dept?currentPage=${page.currentPage+1}">下一页</a>
            </c:if>
            <a href="/dept?currentPage=${page.totalPage}">末页</a>
        </td>
    </tr>
</table>
<script src="/static/layui/layui.js"></script>
<script>
    layui.use(function(){
        var layer = layui.layer;

    });
    function deleteDept(id) {
        // Welcome
        layer.confirm('是否删除这个部门信息？', {icon: 3}, function(){
            location.href = "deleteDept?id="+id;
        }, function(){
        });
    }
</script>
</body>
</html>
